package com.lanbu.system.service.impl;
import com.lanbu.system.domain.mongo.MongoTeams;
import com.lanbu.system.mapper.MongoTeamsRepository;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class MongoTeamsService {

    private final MongoTeamsRepository teamsRepository;

    @Autowired
    public MongoTeamsService(MongoTeamsRepository teamMembersRepository) {
        this.teamsRepository = teamMembersRepository;
    }


    public List<MongoTeams> findAll() {
        return teamsRepository.findAll();
    }



    public Optional<MongoTeams> findById(ObjectId id) {
        return teamsRepository.findById(id);
    }
    public MongoTeams findByOwnerId(ObjectId ownerId) {
        MongoTeams byOwnerId = teamsRepository.findByOwnerId(ownerId);

        System.out.println("o"+byOwnerId);
        return byOwnerId;
    }

    public MongoTeams save(MongoTeams teamMember) {
        return teamsRepository.save(teamMember);
    }


    public void deleteById(ObjectId id) {
        teamsRepository.deleteById(id);
    }


}
